package com.share.shareplatform.util.check;


import com.share.shareplatform.pojo.Goods;
import com.share.shareplatform.pojo.Shop;
import com.share.shareplatform.util.Result;

public class GoodsCheck {





    public static Result checkNameFail(int n){
        if(n==1){
            return Result.getInstance(505,"名称不能为空");
        }else if(n==2){
            return Result.getInstance(505,"名称太长");
        }
        return Result.getInstance(505,"未知错误");
    }

    /*
     * return 0 表示正确
     *        1 为空
     *        2 太长
     * */
    public static int checkName(String s){

        if(s==null||s.trim().equals("")){
            return 1;
        }
        if(s.trim().length()>20){
            return 2;
        }
        return 0;
    }

    public static Result checkIntroduceFail(int n){
        if(n==1){
            return Result.getInstance(505,"介绍不能为空");
        }else if(n==2){
            return Result.getInstance(505,"介绍太长");
        }
        return Result.getInstance(505,"未知错误");
    }

    /*
     * return 0 表示正确
     *        1 为空
     *        2 太长
     * */
    public static int checkIntroduce(String s){

        if(s==null||s.trim().equals("")){
            return 1;
        }
        if(s.trim().length()>200){
            return 2;
        }
        return 0;
    }

    public static Result checkPlaceFail(int n){
        if(n==1){
            return Result.getInstance(505,"出产地不能为空");
        }else if(n==2){
            return Result.getInstance(505,"出产地太长");
        }
        return Result.getInstance(505,"未知错误");
    }

    /*
     * return 0 表示正确
     *        1 为空
     *        2 太长
     * */
    public static int checkPlace(String s){

        if(s==null||s.trim().equals("")){
            return 1;
        }
        if(s.trim().length()>20){
            return 2;
        }
        return 0;
    }

    public static Result checkNumberFail(int n){
        if(n==1){
            return Result.getInstance(505,"数量不符合要求");
        }
        return Result.getInstance(505,"未知错误");
    }

    /*
     * return 0 表示正确
     *        1 为空
     *        2 太长
     * */
    public static int checkNumber(Integer num){
        if(num==null||num<0){
            return 1;
        }
        return 0;
    }

    public static Result checkPriceFail(int n){
        if(n==1){
            return Result.getInstance(505,"价格不符合要求");
        }
        return Result.getInstance(505,"未知错误");
    }

    /*
     * return 0 表示正确
     *        1 为空
     *        2 太长
     * */
    public static int checkPrice(Double price){
        if(price==null||price<0){
            return 1;
        }
        return 0;
    }


    public static void setUnAlter(Goods goods){
        goods.setDeal(null);
    }


}
